package com.atguigu.springcloud.config;

import org.springframework.cloud.gateway.route.RouteDefinition;
import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class GatewayConfig {


    @Bean
    public RouteLocator gatewayRoute(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        RouteLocator routeLocator = routes.route("path_route_baidi_news_guonei", r -> r.path("/guonei").uri("http://news.baidu.com/guonei")).build();
        return routeLocator;
    }
    @Bean
    public RouteLocator gatewayRoute2(RouteLocatorBuilder routeLocatorBuilder){
        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        RouteLocator routeLocator = routes.route("path_route_baidi_news_guowai", r -> r.path("/guoji").uri("http://news.baidu.com/guoji")).build();
        return routeLocator;
    }
}
